﻿<!DOCTYPE html>
<html>
<head>  
    <link href="../../Content/bootstrap/css/bootstrap.css" rel="stylesheet" />
    <link href="../../Content/Custom.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="top">
        <div id="banner" class="radial-center">
            <div id="user-info">
                @if (this.Session["username"] != null)
                {
                    @Html.Raw("Chào mừng " + this.Session["username"].ToString()
                    + " <a class='btn btn-info btn-mini' href='#' onclick='Logout();return false;'>Đăng xuất</a>");
                }
                else
                {
                    <a class='btn btn-info btn-mini' href='#' onclick='ShowLoginForm();return false;'>Đăng
                        nhập</a>
                }
            </div>
        </div>
        <div id="menu">
            <div class="navbar navbar-inverse">
                <div class="navbar-inner">
                    <div class="container">
                        <a class="btn btn-navbar" data-toggle="collapse" data-target=".navbar-responsive-collapse">
                            <span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar">
                            </span></a><a class="brand" href="/">Movie365</a>
                        <div class="nav-collapse collapse navbar-responsive-collapse">
                            <ul class="nav">
                                <li class=""><a href="/">Trang chủ</a></li>
                                <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Thể
                                    loại phim<b class="caret"></b></a>
                                    <ul class="dropdown-menu">
                                        @foreach (var cat in Model.ListCategory)
                                        {                                        
                                            <li><a href="/Category/View/@cat.ID">@cat.Name</a></li>
                                        }
                                    </ul>
                                </li>
                            </ul>
                            <form class="navbar-search pull-right" action="/Search/Index">
                            <input class="search-query span2" placeholder="Tìm kiếm" name="keyword" type="text" />
                            </form>
                        </div>
                        <!-- /.nav-collapse -->
                    </div>
                </div>
                <!-- /navbar-inner -->
            </div>
            <!-- /navbar -->
        </div>
    </div>
    <div id="wrap">
        <!-- Content -->
        <div id="content">
            @RenderBody()
        </div>
        <!-- End content -->
        <div id="right-nav">
            <div id="top-film">
                <div class="tabbable">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab1" data-toggle="tab">Phim hay</a></li>
                        <li><a href="#tab2" data-toggle="tab">Phim mới</a></li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="tab1">
                            <ul>
                                @foreach (var item in Model.TopFilm)
                                {
                                    <li><a href="/Film/View/@item.ID">@item.ShortTitle</a>
                                        <p style="font-size: 12px; color: Red">
                                            Lượt view : @item.ViewCount</p>
                                    </li>
                                }
                            </ul>
                        </div>
                        <div class="tab-pane" id="tab2">
                            <ul>
                                @foreach (var item in Model.NewFilm)
                                {
                                    <li><a href="/Film/View/@item.ID">@item.ShortTitle</a>
                                        <p style="font-size: 12px; color: Red">
                                            Lượt view : @item.ViewCount</p>
                                    </li>
                                }
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="footer" class="radial-center">
        <ul id="footer-text" class="unstyled">
            <li>
                <center>
                    Assignment SAD: web film</center>
            </li>
            <li>Group 2 members:</li>
            <li>
                <ol>
                    <li>Phan Văn Minh</li>
                    <li>Nguyễn Huỳnh Xuân Tài</li>
                    <li>Mai Văn Tân</li>
                    <li>Phạm Viết Thành</li>
                </ol>
            </li>
        </ul>
    </div>
    <!-- Modal Login -->
    <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
        aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                ×</button>
            <h3 id="myModalLabel">
                Đăng nhập</h3>
        </div>
        <div class="modal-body">
            <form action="" />
            <table>
                <tr>
                    <td>
                        Tài khoản:
                    </td>
                    <td>
                        <input id="username" type="text" name="username" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Mật khẩu:
                    </td>
                    <td>
                        <input id="password" type="password" name="password" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <a href="/Account/Register">Chưa có tài khoản?</a>
                    </td>
                </tr>
            </table>
            </form>
        </div>
        <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">
                Hủy</button>
            <button class="btn btn-primary" id="submit-info">
                Đăng nhập</button>
        </div>
    </div>
    <script src="/Content/bootstrap/js/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="/Content/bootstrap/js/bootstrap.js" type="text/javascript"></script>
    <script src="/Content/bootstrap/js/holder.js" type="text/javascript"></script>
    <script type="text/javascript">
        $('#password').keypress(function(e) {
            if(e.which == 13) {
                $(this).blur();
                $('#submit-info').focus().click();
            }
        });

        function ShowLoginForm() {
            $('#myModal').modal('show');                          
        }

        function Logout()
        {
             $.ajax({
			    type : "Post",
			    url : "/Account/Logout",
			    data : "",
			    success : function(data){					   
                        $("#user-info").html('<a class="btn btn-info btn-mini" href="#" onclick="ShowLoginForm();return false;">Đăng nhập</a>');
                        $("#comment-username").val("");                                                   
       	    	    },
       		    error : function(){
       				    
       			    },
  			    complete : function(){ 
  					    
  				    },
		    });       
        }

        $("#submit-info").click(function (e) {
            var username= $('#username');
            var password = $('#password');
            var dataPost = "username="+username.val()+"&password="+password.val();
            $.ajax({
			    type : "Post",
			    url : "/Account/Login",
			    data : dataPost,
			    success : function(data){
					    $("#loadingmessage").hide();
                        if(data != "Fail")
                        {
                            $("#user-info").html('Chào mừng '+data
                            +' <a class="btn btn-info btn-mini" href="#" onclick="Logout();return false;">Đăng xuất</a>');
                            $("#comment-username").val(data);
                            username.val("");
                            password.val("");

                            $("#submit-info").removeClass("disabled");		
  					        $('#myModal').modal('hide');
                        }else
                        {
                            alert("Login fail!");
                        }
       	    	    },
       		    error : function(){
       				    console.log('Login Error');
       			    },
  			    complete : function(){   					    
  				    },
		    });        
        });
    </script>
</body>
</html>
